package com.mt.mall.entity.Order;

import javax.persistence.*;
import java.io.Serializable;
import com.mt.common.core.annotation.DColumn;
import com.mt.common.core.annotation.DEntity;
import com.mt.common.core.web.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;



import com.mt.common.system.entity.Attachment;
import com.mt.common.system.entity.User;
import com.mt.mall.entity.User.ShippingAddress;
import java.util.Date;
import com.mt.mall.entity.merchant.Shop;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.mt.mall.entity.good.Commodity;
import java.util.List;

@DEntity(label="订单",comment="",moduleLabel="订单")
@Entity(name="mall_order")
@Table(name = "mall_order" , indexes = { @Index(name = "index_commodity_id", columnList = "commodity_id"),@Index(name = "index_user_id", columnList = "user_id"),@Index(name = "index_user_address_id", columnList = "user_address_id"),@Index(name = "index_shop_id", columnList = "shop_id"),@Index(name = "index_order_status", columnList = "order_status")  })
@ApiModel(description = "订单:")
public class Order extends BaseEntity implements Serializable{
	private static final long serialVersionUID = 1L;

	@DColumn(index=3,label="订单号",comment="订单编号",component="文本",where=false)
	@ApiModelProperty(value = "订单号:订单编号")
	@Column(name="code",length=255,nullable=false,unique=false)
	private String code;

	@DColumn(index=4,label="商品",foreignEntity="Commodity",comment="",component="对象选择",where=false)
	@ApiModelProperty(value = "商品:")
	@Column(name="commodity_id",length=255,nullable=false,unique=false)
	private Long commodityId;

	@Transient
	private Commodity commodity;

	@Transient
	@ApiModelProperty(value = "商品名称:")
	@DColumn(index=4,label="商品",foreignEntity="Commodity",comment="")
	private String commodityName;

	@Transient
	private String imageUrl;

	@DColumn(index=5,label="规格",comment="将所选择的规格用-拼接",component="文本",where=false)
	@ApiModelProperty(value = "规格:将所选择的规格用-拼接")
	@Column(name="specification",length=255,nullable=true,unique=false)
	private String specification;

	@DColumn(index=6,label="购买规格数量",comment="购买规格数量",component="整数",where=false)
	@ApiModelProperty(value = "购买规格数量")
	@Column(name="count",length=255,nullable=true,unique=false)
	private Integer count;

	@DColumn(index=6,label="订单总额",comment="订单总额",component="小数",where=false)
	@ApiModelProperty(value = "订单总额")
	@Column(name="price",length=255,nullable=true,unique=false)
	private Double price;

	@Transient
	private List<Attachment> attachments;

	@DColumn(index=7,label="购买用户",foreignEntity="User",comment="购买用户",component="对象选择",where=false)
	@ApiModelProperty(value = "购买用户:购买用户")
	@Column(name="user_id",length=255,nullable=false,unique=false)
	private Long userId;

	@Transient
	private User user;

	@Transient
	@ApiModelProperty(value = "购买用户名称:购买用户")
	@DColumn(index=7,label="购买用户",foreignEntity="User",comment="购买用户")
	private String userName;

	@DColumn(index=8,label="用户地址",foreignEntity="ShippingAddress",comment="用户地址",component="对象选择",where=false)
	@ApiModelProperty(value = "用户地址:用户地址")
	@Column(name="user_address_id",length=255,nullable=false,unique=false)
	private Long userAddressId;

	@Transient
	private ShippingAddress userAddress;

	@Transient
	@ApiModelProperty(value = "用户地址名称:用户地址")
	@DColumn(index=8,label="用户地址",foreignEntity="ShippingAddress",comment="用户地址")
	private String userAddressName;

	@Transient
	@ApiModelProperty(value = "用户地址名称:用户地址")
	@DColumn(index=8,label="用户地址",foreignEntity="ShippingAddress",comment="用户地址")
	private String userDeatailedAddress;

	@DColumn(index=9,label="店铺",foreignEntity="Shop",comment="店铺",component="对象选择",where=false)
	@ApiModelProperty(value = "店铺:店铺")
	@Column(name="shop_id",length=255,nullable=true,unique=false)
	private Long shopId;

	@Transient
	private Shop shop;

	@Transient
	@ApiModelProperty(value = "店铺名称:店铺")
	@DColumn(index=9,label="店铺",foreignEntity="Shop",comment="店铺")
	private String shopName;

	@DColumn(index=9,label="秒杀商品ID",foreignEntity="SkillCommodity",comment="秒杀商品的ID，这个字段不为空代表这个订单为秒杀生成的订单",component="对象选择",where=false)
	@ApiModelProperty(value = "秒杀订单:秒杀订单")
	@Column(name="skill_commodity_id",length=255,nullable=true,unique=false)
	private Long skillCommodityId;

	@DColumn(index=10,label="订单状态",codeTable="订单状态",codeTableOptions="下单,待发货,已发货,待签收,已签收,订单完成,退货中,完成退货",comment="订单状态",component="字典下拉单选",where=false)
	@ApiModelProperty(value = "订单状态:订单状态")
	@Column(name="order_status",length=255,nullable=false,unique=false)
	private String orderStatus;

	@DColumn(index=11,label="付款时间",comment="付款时间",component="日期选择",where=false)
	@ApiModelProperty(value = "付款时间:付款时间")
	@Column(name="pay_time",length=255,nullable=true,unique=false)
	@JsonSerialize(using = DateSerializer.class)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date payTime;

	@DColumn(index=12,label="发货时间",comment="付款时间",component="日期选择",where=false)
	@ApiModelProperty(value = "发货时间:付款时间")
	@Column(name="delivery_time",length=255,nullable=true,unique=false)
	@JsonSerialize(using = DateSerializer.class)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date deliveryTime;

	@DColumn(index=13,label="签收时间",comment="签收时间",component="日期选择",where=false)
	@ApiModelProperty(value = "签收时间:签收时间")
	@Column(name="sign_time",length=255,nullable=true,unique=false)
	@JsonSerialize(using = DateSerializer.class)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date signTime;

	@DColumn(index=14,label="完成时间",comment="完成时间",component="日期选择",where=false)
	@ApiModelProperty(value = "完成时间:完成时间")
	@Column(name="complete_time",length=255,nullable=true,unique=false)
	@JsonSerialize(using = DateSerializer.class)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date completeTime;

	@DColumn(index=15,label="收件人",comment="收件人",component="文本",where=true)
	@ApiModelProperty(value = "收件人:收件人")
	@Column(name="recipient",length=20,nullable=false,unique=false)
	private String recipient;

	@DColumn(index=16,label="电话号码",comment="电话号码",component="文本",where=true)
	@ApiModelProperty(value = "电话号码:电话号码")
	@Column(name="phone",length=20,nullable=false,unique=false)
	private String phone;

	@DColumn(index=17,label="详细地址",comment="详细地址",component="文本",where=false)
	@ApiModelProperty(value = "详细地址:详细地址")
	@Column(name="detailed_address",length=255,nullable=true,unique=false)
	private String detailedAddress;

	public String getRecipient() {
		return recipient;
	}

	public void setRecipient(String recipient) {
		this.recipient = recipient;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getDetailedAddress() {
		return detailedAddress;
	}

	public void setDetailedAddress(String detailedAddress) {
		this.detailedAddress = detailedAddress;
	}

	public void setUserAddress(ShippingAddress userAddress) {
		this.userAddress = userAddress;
	}

	public String getUserDeatailedAddress() {
		return userDeatailedAddress;
	}

	public void setUserDeatailedAddress(String userDeatailedAddress) {
		this.userDeatailedAddress = userDeatailedAddress;
	}

	public Integer getCount() {
		return count;
	}

	public Long getSkillCommodityId() {
		return skillCommodityId;
	}

	public void setSkillCommodityId(Long skillCommodityId) {
		this.skillCommodityId = skillCommodityId;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Long getCommodityId() {
		return this.commodityId;
	}

	public void setCommodityId(Long commodityId) {
		this.commodityId = commodityId;
	}

	public String getSpecification() {
		return this.specification;
	}

	public void setSpecification(String specification) {
		this.specification = specification;
	}

	public List<Attachment> getAttachments() {
		return this.attachments;
	}

	public void setAttachments(List<Attachment> attachments) {
		this.attachments = attachments;
	}

	public Long getUserId() {
		return this.userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Long getUserAddressId() {
		return this.userAddressId;
	}

	public void setUserAddressId(Long userAdressId) {
		this.userAddressId = userAdressId;
	}

	public Long getShopId() {
		return this.shopId;
	}

	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}

	public String getOrderStatus() {
		return this.orderStatus;
	}

	public void setOrderStatus(String orderStatus) {
		this.orderStatus = orderStatus;
	}

	public Date getPayTime() {
		return this.payTime;
	}

	public void setPayTime(Date payTime) {
		this.payTime = payTime;
	}

	public Date getDeliveryTime() {
		return this.deliveryTime;
	}

	public void setDeliveryTime(Date deliveryTime) {
		this.deliveryTime = deliveryTime;
	}

	public Date getSignTime() {
		return this.signTime;
	}

	public void setSignTime(Date signTime) {
		this.signTime = signTime;
	}

	public Date getCompleteTime() {
		return this.completeTime;
	}

	public void setCompleteTime(Date completeTime) {
		this.completeTime = completeTime;
	}

	public Commodity getCommodity() {
		return this.commodity;
	}

	public void setCommodity(Commodity commodity) {
		if(commodity == null){
		}
		else
		{
		this.commodityId = commodity.getEid();
		this.commodity = commodity;		
		}
}

	public String getCommodityName() {
		return this.commodityName;
	}

	public void setCommodityName(String commodityName) {
		this.commodityName = commodityName;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		if(user == null){
		}
		else
		{
		this.userId = user.getEid();
		this.user = user;		
		}
}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public ShippingAddress getUserAddress() {
		return this.userAddress;
	}

	public void setUserAdrdess(ShippingAddress userAdress) {
		if(userAdress == null){
		}
		else
		{
		this.userAddressId = userAdress.getEid();
		this.userAddress = userAdress;
		}
}

	public String getUserAddressName() {
		return this.userAddressName;
	}

	public void setUserAddressName(String userAdressName) {
		this.userAddressName = userAdressName;
	}

	public Shop getShop() {
		return this.shop;
	}

	public void setShop(Shop shop) {
		if(shop == null){
		}
		else
		{
		this.shopId = shop.getEid();
		this.shop = shop;		
		}
}

	public String getShopName() {
		return this.shopName;
	}

	public void setShopName(String shopName) {
		this.shopName = shopName;
	}



}
